import React, { useEffect, useState } from "react";
import request from "../../axios/request.js";
import { useParams } from "react-router-dom";
const Index = () => {
  const { id } = useParams();
  const [list, setlist] = useState([]);
  const getData = async () => {
    const res = await request.get("/api/list/detail", { params: { id } });
    const { code, data } = res.data;
    if (code == 200) {
      setlist(data);
      console.log(data);
    }
  };
  useEffect(() => {
    getData();
  }, []);
  return (
    <div>
      <div>
        <img src={list.image}></img>
        <p>{list.title}</p>
        <p>￥{list.price}</p>
      </div>
    </div>
  );
};

export default Index;
